<?php

function __( $text, $domain = 'default' ) {
	$translations = &get_translations( $domain );
	return $translations->translate( $text );
}
function _e( $text, $domain = 'default' ) {
	echo __( $text, $domain );
}

function _n( $singular, $plural, $count, $domain = 'default' ) {
	$translations = &get_translations( $domain );
	return $translations->translate_plural( $singular, $plural, $count );
}
function _ne( $singular, $plural, $count, $domain = 'default' ) {
	echo _n( $singular, $plural, $count, $domain );
}

function _x( $text, $context, $domain = 'default' ) {
	$translations = &get_translations( $domain );
	return $translations->translate( $text, $context );
}
function _xe( $text, $context, $domain = 'default' ) {
	echo _x( $text, $context, $domain );
}

function _nx( $singular, $plural, $context, $count, $domain = 'default' ) {
	$translations = &get_translations( $domain );
	return $translations->translate_plural( $singular, $plural, $count, $context );
}
function _nxe( $singular, $plural, $context, $count, $domain = 'default' ) {
	echo _nx( $singular, $plural, $count, $context, $domain );
}

function _n_noop( $single, $plural ) {
	return array( $single, $plural );
}
function _nx_noop( $single, $plural, $context ) {
	return array( $single, $plural, $context );
}

function esc_attr__( $text, $domain = 'default' ) {
	return esc_attr( __( $text, $domain ) );
}
function esc_attr_e( $text, $domain = 'default' ) {
	echo esc_attr__( $text, $domain );
}

function esc_html__( $text, $domain = 'default' ) {
	return esc_html( __( $text, $domain ) );
}
function esc_html_e( $text, $domain = 'default' ) {
	echo esc_html__( $text, $domain );
}

function &load_translations( $mo_filename ) {
	if ( is_readable( $mo_filename ) ) {
		$translations = new MO();
		$translations->import_from_file( $mo_filename );
	} else {
		$translations = new Translations();
	}
	return $translations;
}

$translations = array();
$empty_translations =& new Translations();

function load_textdomain( $domain, $prefix ) {
	global $translations;
	$translations[$domain] =& load_translations( $prefix . '-' . FRONTPRESS_LOCALE . '.mo' );
}

function &get_translations( $domain ) {
	global $translations, $empty_translations;
	return isset( $translations[$domain] ) ? $translations[$domain] : $empty_translations;
}